var jsToolGameDemo=[
	`//黑白棋
if(!this.moonjs){
	this.moonjs=new MoonBit101();
	this.moonjs.init(canvas);
	this.moonjs.setGapXY(this.p.x,this.p.y);//设置偏移量
}
let moonjs=this.moonjs;
moonjs.start();
canvas.color='#00FF00';
game();
function game(){
	const [black,white]=['#000000','#FFFFFF']
	const boxs=[];
	const array=[];
	let isPlay=false;
	let doArr=[];
	let ang=0;
	let isWrite=false;
	for(let i=0;i<4;i++){
		let arr=[];
		array.push(arr);
		for(let j=0;j<4;j++){
			let b=moonjs.createDisplay('rect').setWH(95,95);
			b.setColor(white);
			b.name=i+','+j;
			moonjs.click(b,onClick)
			boxs.push(b);
			arr.push(b);
		}
	}
	moonjs.displayRank(boxs,4,4,4,50,50);
	function onClick(b){
		if(isWrite){
			changeColor(b);
			return;
		}
		let as=b.name.split(',');
		let [i,j]=[parseInt(as[0]),parseInt(as[1])];
		doArr.length=0;
		doArr.push(array[i][j]);
		if(i>0) doArr.push(array[i-1][j]);
		if(j>0) doArr.push(array[i][j-1]);
		if(i<3) doArr.push(array[i+1][j]);
		if(j<3) doArr.push(array[i][j+1]);
		isPlay=true;
		ang=0;
	}
	function changeColor(b){
		b.color===black?b.setColor(white):b.setColor(black);
	}
	function log(...arg){
		console.log(...arg);
	}
	function changeGameOver(){
		let isOver=boxs.every((a)=>a.color===white);
		if(isOver){
			TipsManager.alert('恭喜你过关')
		}
	}
	function initTitle(arr){
		for(let i=0;i<16;i++){
			let [a,b]=[arr[i],boxs[i]];
			a==='0'?b.setColor(black):b.setColor(white);
		}
	}
	moonjs.update=()=>{
		if(isPlay){
			ang+=10;
			if(ang>=90){
				isPlay=false;
				ang=0;
			}
			for(let k=0;k<doArr.length;k++){
				doArr[k].a=ang;
				if(ang==0) changeColor(doArr[k]);
			}
			if(ang==0) changeGameOver();
		}
	}
	
	let initTitles=[['0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0']
	,['1,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1']
	,['0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0']]
	let len=initTitles.length;
	for(let i=0;i<len;i++){
		let btn=moonjs.createRectText('第-'+(i+1)+'-题');
		btn.name=i;
		btn.setXY(50+i*80,440);
		moonjs.click(btn,(b)=>{
			let i=parseInt(b.name);
			isWrite=false;
			let arr=initTitles[i][0].split(',');
			initTitle(arr);
		})
	}
}
`,`//躲避子弹
if(!this.moonjs){
	this.moonjs=new MoonBit101();
	this.moonjs.init(canvas);
	this.moonjs.setGapXY(this.p.x,this.p.y);//设置偏移量
}
canvas.color='#000';
let moonjs=this.moonjs;
moonjs.start();
game();
function game(){
	let [w,h,enemys,total,sv,time]=[canvas.width,canvas.height,[],10,2,0];
	let timeNum=(new Date).valueOf();
	createEnemys();
	function createEnemys(){
		for(let i=0;i<total;i++){
			let enemy=moonjs.createDisplay('circle')
			enemy.setRadius(3)
			enemy.setXY(Math.random()*w,Math.random()*h);
			enemy.color=moonjs.randomColor();
			enemy.sx=Math.random()*sv;
			enemy.sy=Math.random()*sv;
			(Math.random()<0.5)&&(enemy.sx*=-1);
			(Math.random()<0.5)&&(enemy.sy*=-1);
			enemys.push(enemy);
		}
	}
	let player=moonjs.createDisplay('polygon');
	player.setSides([[0,-29],[29,25],[0,13],[-27,25],[0,-29]]);
	player.setColor('#ff0000');
	player.setXY(w/2,h/2);
	player.setScale(0.3);
	player.sx=0;
	player.sy=0;
	moonjs.addKeyboard((e)=>{
		let key=moonjs.keyToLower(e.key);
		switch(key){
			case 'a':player.sx=-1;break;
			case 'd':player.sx=1;break;
			case 'w':player.sy=-1;break;
			case 's':player.sy=1;break;
		}
		},(e)=>{
			let key=moonjs.keyToLower(e.key);
			switch(key){
				case 'a':player.sx=0;break;
				case 'd':player.sx=0;break;
				case 'w':player.sy=0;break;
				case 's':player.sy=0;break;
			}
	});
	moonjs.update=()=>{
		player.x+=player.sx*sv;
		player.y+=player.sy*sv;
		let len=enemys.length;
		for(let i=0;i<len;i++){
			let enemy=enemys[i];
			enemy.x+=enemy.sx;
			enemy.y+=enemy.sy;
			if(enemy.x<0||enemy.x>w) enemy.sx*=-1;
			if(enemy.y<0||enemy.y>h) enemy.sy*=-1;
			if(enemy.hitTarget(player,6)){
				moonjs.stop();
				timeNum=((new Date).valueOf()-timeNum);
				TipsManager.alert('坚持 '+parseInt(timeNum/1000)+' 秒游戏结束',2000);
			}
		}
		time++;
		if(time%500==0){
			createEnemys();
			time=0;
		}
	}
}
`,`//落下的弹珠
if(!this.mb){
	this.mb=new MoonBox2d();
	this.mb.box2dInit(canvas,1);
	this.mb.openMouseEvent();
 }
 let mb=this.mb;
 mb.reInit();
 for(let i=0;i<100;i++){
	mb.createCircle(120,100,4);
 }
 let datas=[[41,304,20,20,12,'circle',0,0],
 [83,304,20,20,12,'circle',0,0],
 [125,304,20,20,12,'circle',0,0],
 [167,304,20,20,12,'circle',0,0],
 [209,304,20,20,12,'circle',0,0],
 [59,348,20,20,12,'circle',0,0],
 [101,348,20,20,12,'circle',0,0],
 [143,348,20,20,12,'circle',0,0],
 [185,348,20,20,12,'circle',0,0],
 [21,393,20,20,12,'circle',0,0],
 [71,390,20,20,12,'circle',0,0],
 [120,392,20,20,12,'circle',0,0],
 [168,390,20,20,12,'circle',0,0],
 [220,393,20,20,12,'circle',0,0],
 [62,262,20,20,12,'circle',0,0],
 [104,262,20,20,12,'circle',0,0],
 [146,262,20,20,12,'circle',0,0],
 [188,262,20,20,12,'circle',0,0],
 [245,339,3,290,20,'rect',0,0],
 [4,334,3,290,20,'rect',0,0],
 [120,626,142,3,20,'rect',0,0],
 [52,559,3,65,20,'rect',0,0],
 [97,559,3,65,20,'rect',0,0],
 [196,557,3,65,20,'rect',0,0],
 [146,561,3,65,20,'rect',0,0]]
 for(let i=0;i<25;i++){
	 let as=datas[i];
	 let [x,y,w,h,r,t1,a,t2]=[as[0],as[1],as[2],as[3],as[4],as[5],as[6],as[7]]
	 let body=mb.createBody({t1:t1,x:x,y:y,w:w,h:h,r:r,t2:t2});
	 mb.setAngle(body,a);
 }
 
`,``
]